package cn.edu.nuc.weiboclient;

import java.util.HashMap;
import java.util.Map;

import oauth.signpost.OAuth;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import cn.edu.nuc.modle.WeiBoData;
import cn.edu.nuc.modle.WeiBoList;

import com.google.gson.Gson;

public class ShowOneWeiBo extends Activity{
	private SharedPreferences prefs;
	private ImageView showHeadImage = null;
	private ImageView showImage = null;
	private TextView showNick = null;
	private TextView showName = null;
	private Button informationButton = null;
	private TextView showTweet = null;
	private TextView showTime = null;
	private Button backButton = null;
	private Button homeButton = null;
	private Context context = null;
	private AsyncImageLoader loader = new AsyncImageLoader();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.item);
		prefs = PreferenceManager.getDefaultSharedPreferences(this);
		
		showHeadImage =(ImageView)findViewById(R.id.itemPhotoId);
		showImage = (ImageView)findViewById(R.id.itemImageId);
		showNick = (TextView)findViewById(R.id.itemNickTextViewId);
		showName = (TextView)findViewById(R.id.itemNameTextViewId);
		informationButton =(Button)findViewById(R.id.itemInformationId) ;
		showTweet = (TextView)findViewById(R.id.itemTweetId);
		showTime = (TextView)findViewById(R.id.itemTimeId);
		backButton = (Button)findViewById(R.id.itemBackButtonId);
		homeButton = (Button)findViewById(R.id.itemHomeButtonId);
		
		Intent intent = getIntent();
		
		showNick.setText(intent.getStringExtra("nick"));
		showName.setText("@"+intent.getStringExtra("name"));
		showTweet.setText(intent.getStringExtra("tweet"));
	
		//	String date  = new java.text.SimpleDateFormat
	//	("HH:mm").format(new java.util.Date(Integer.parseInt(intent.getStringExtra("time"))*1000)) ;
	//	showTime.setText(date);
		if(!intent.getStringExtra("headImage").equals("")){
			Drawable headDrawable = loader.loadDrawable(intent.getStringExtra("headImage") + "/50", new AsyncImageLoader.ImageCallback() {			
				@Override
				public void imageLoaded(Drawable imageDrawable) {
					showHeadImage.setImageDrawable(imageDrawable);
				}
			});
			if(headDrawable != null){
				showHeadImage.setImageDrawable(headDrawable);
			}
		}
		else{
				showHeadImage.setImageResource(R.drawable.icon);
		}
		if(intent.getStringExtra("image") != null){
			Drawable weiBoImageDrawable = loader.loadDrawable(intent.getStringExtra("image") + "/460", new AsyncImageLoader.ImageCallback() {				
				@Override
				public void imageLoaded(Drawable imageDrawable) {
					showImage.setImageDrawable(imageDrawable);
				}
			});
			if(weiBoImageDrawable != null){
				showImage.setImageDrawable(weiBoImageDrawable);
			}
		}
	}
	
}
